package com.jingzhun.schedule;

import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author wangDan
 * @data 2019/7/17 0017 19:33
 */
public class QuartzTest {
    public static void main1(String[] args) {
        ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("classpath:applicationContext.xml");
        QuartzManager quartzManager = (QuartzManager) applicationContext.getBean("quartzManager");
        try {
            System.out.println("【系统启动】开始(每1秒输出一次)...");
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
//    private static Scheduler scheduler;
    public static void main(String[] args) {
        ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("classpath:applicationContext.xml");
        QuartzManager quartzManager = (QuartzManager) applicationContext.getBean("quartzManager");
        try {
            System.out.println("【系统启动】开始(每1秒输出一次 job2)...");
//            Thread.sleep(5000);
            System.out.println("【增加job1启动】开始(每1秒输出一次)...");
//            quartzManager.addJob("test", "test", "test", "test", MyJob.class, "0/1 * * * * ?");
//            Thread.sleep(5000);
//            System.out.println("【修改job1时间】开始(每2秒输出一次)...");
//            quartzManager.modifyJobTime("test", "test", "test", "test", "0/2 * * * * ?");
//            Thread.sleep(10000);
//            System.out.println("【移除job1定时】开始...");
//            quartzManager.removeJob("test", "test", "test", "test");
            // 关掉任务调度容器
//             quartzManager.shutdownJobs();
//             打开所有任务调度
            quartzManager.startJobs();
            System.out.println("关闭");

//            移除
//            quartzManager.removeJob("test", "test", "test", "test");
//            暂停
                quartzManager.pauseJob("test","test");
//            重启
//            quartzManager.resumeJob("test","test");
//            scheduler.start();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
